package struts.action.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {

	@SuppressWarnings("rawtypes")
	public static ActionForm full(String formPath, HttpServletRequest request) {
		ActionForm form = null;
		try {
			Class clazz=Class.forName(formPath);
			form = (ActionForm) clazz.newInstance();
			Field [] fields=clazz.getDeclaredFields();
			for (Field field : fields) {
				field.setAccessible(true);
				field.set(form,request.getParameter(field.getName()));
				field.setAccessible(false);
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return form;
	}
}
